```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>装饰器设计模式：动态添加功能的灵活选择</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8fafc;
            color: #1e293b;
        }
        .hero {
            background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
            color: white;
        }
        .section-title {
            position: relative;
            padding-bottom: 1rem;
        }
        .section-title:after {
            content: "";
            position: absolute;
            bottom: 0;
            left: 0;
            width: 3rem;
            height: 3px;
            background: linear-gradient(90deg, #6366f1, #8b5cf6);
            border-radius: 3px;
        }
        .card {
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .code-block {
            background-color: #1e293b;
            border-radius: 0.5rem;
            color: #e2e8f0;
        }
        .code-keyword {
            color: #f472b6;
        }
        .code-class {
            color: #60a5fa;
        }
        .code-function {
            color: #34d399;
        }
        .code-string {
            color: #fbbf24;
        }
        .code-comment {
            color: #94a3b8;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero py-20 px-4">
        <div class="container mx-auto max-w-4xl text-center">
            <h1 class="text-4xl md:text-5xl font-bold mb-4 font-serif">装饰器设计模式</h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">动态添加功能的灵活选择</p>
            <div class="max-w-2xl mx-auto">
                <p class="text-lg leading-relaxed opacity-90">
                    一种结构型设计模式，允许你在不改变对象接口的情况下，动态地为对象添加新的行为。通过创建包装对象来实现，在运行时可以根据需要组合各种不同的功能。
                </p>
            </div>
            <div class="mt-12">
                <i class="fas fa-chevron-down text-2xl opacity-70 animate-bounce"></i>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-4xl px-4 py-16">
        <!-- Features Section -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 section-title">核心特点</h2>
            <div class="grid md:grid-cols-3 gap-6">
                <div class="card bg-white p-6 rounded-lg shadow-md">
                    <div class="text-purple-600 text-3xl mb-4">
                        <i class="fas fa-bolt"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">动态添加功能</h3>
                    <p class="text-gray-600">允许在运行时动态地为对象添加新的功能，不需要修改已有的代码。</p>
                </div>
                <div class="card bg-white p-6 rounded-lg shadow-md">
                    <div class="text-purple-600 text-3xl mb-4">
                        <i class="fas fa-lock-open"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">开放封闭原则</h3>
                    <p class="text-gray-600">支持开放封闭原则，允许扩展现有功能而无需修改现有代码。</p>
                </div>
                <div class="card bg-white p-6 rounded-lg shadow-md">
                    <div class="text-purple-600 text-3xl mb-4">
                        <i class="fas fa-puzzle-piece"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-3">组合灵活性</h3>
                    <p class="text-gray-600">通过不同的组合方式，可以创建出不同的装饰效果。</p>
                </div>
            </div>
        </section>

        <!-- Use Cases Section -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 section-title">使用场景</h2>
            <div class="space-y-6">
                <div class="flex items-start">
                    <div class="bg-purple-100 text-purple-600 rounded-full p-3 mr-4 mt-1">
                        <i class="fas fa-magic text-lg"></i>
                    </div>
                    <div>
                        <h3 class="text-xl font-bold mb-2">动态功能添加</h3>
                        <p class="text-gray-600">当需要在不改变现有类结构的情况下，动态地为对象添加额外的功能时，可以使用装饰器模式。</p>
                    </div>
                </div>
                <div class="flex items-start">
                    <div class="bg-purple-100 text-purple-600 rounded-full p-3 mr-4 mt-1">
                        <i class="fas fa-layer-group text-lg"></i>
                    </div>
                    <div>
                        <h3 class="text-xl font-bold mb-2">多层次的功能组合</h3>
                        <p class="text-gray-600">当需要按照一定的顺序组合多个功能时，可以使用装饰器模式来构建多层嵌套的装饰器。</p>
                    </div>
                </div>
                <div class="flex items-start">
                    <div class="bg-purple-100 text-purple-600 rounded-full p-3 mr-4 mt-1">
                        <i class="fas fa-random text-lg"></i>
                    </div>
                    <div>
                        <h3 class="text-xl font-bold mb-2">不同功能的组合</h3>
                        <p class="text-gray-600">当需要对同一个对象进行不同功能的多种组合时，装饰器模式提供了灵活的选择。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Framework Applications -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 section-title">框架中的应用</h2>
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <div class="flex items-center mb-4">
                        <div class="bg-orange-100 text-orange-600 rounded-full p-3 mr-4">
                            <i class="fab fa-java text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">Java的IO流</h3>
                    </div>
                    <p class="text-gray-600">Java中的InputStream和OutputStream就使用了装饰器模式，通过不同的装饰器组合可以实现不同的数据处理。</p>
                </div>
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <div class="flex items-center mb-4">
                        <div class="bg-green-100 text-green-600 rounded-full p-3 mr-4">
                            <i class="fas fa-leaf text-2xl"></i>
                        </div>
                        <h3 class="text-xl font-bold">Spring框架</h3>
                    </div>
                    <p class="text-gray-600">Spring AOP使用装饰器模式实现，通过动态代理技术在方法前后添加不同的切面功能。</p>
                </div>
            </div>
        </section>

        <!-- Diagram Section -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 section-title">模式图解</h2>
            <div class="bg-white p-6 rounded-lg shadow-md">
                <div class="mermaid">
                    classDiagram
                        class Component {
                            +operation()
                        }
                        class ConcreteComponent {
                            +operation()
                        }
                        class Decorator {
                            -component: Component
                            +operation()
                        }
                        class ConcreteDecoratorA {
                            +operation()
                            +addedBehavior()
                        }
                        class ConcreteDecoratorB {
                            +operation()
                            +addedState
                            +addedBehavior()
                        }

                        Component <|-- ConcreteComponent
                        Component <|-- Decorator
                        Decorator o-- Component
                        Decorator <|-- ConcreteDecoratorA
                        Decorator <|-- ConcreteDecoratorB
                </div>
            </div>
        </section>

        <!-- Code Example -->
        <section class="mb-20">
            <h2 class="text-3xl font-bold mb-8 section-title">实现示例</h2>
            <p class="text-gray-600 mb-6">以下是一个简单的装饰器模式示例，使用装饰器来为手机添加不同的功能：</p>
            <div class="code-block p-6 rounded-lg overflow-x-auto">
                <pre><code class="language-java">
<span class="code-comment">// 手机接口</span>
<span class="code-keyword">interface</span> <span class="code-class">Phone</span> {
    <span class="code-keyword">void</span> <span class="code-function">features</span>();
}

<span class="code-comment">// 基础手机</span>
<span class="code-keyword">class</span> <span class="code-class">BasicPhone</span> <span class="code-keyword">implements</span> <span class="code-class">Phone</span> {
    <span class="code-keyword">public</span> <span class="code-keyword">void</span> <span class="code-function">features</span>() {
        System.<span class="code-keyword">out</span>.println(<span class="code-string">"Basic phone with calling and texting"</span>);
    }
}

<span class="code-comment">// 装饰器基类</span>
<span class="code-keyword">abstract</span> <span class="code-keyword">class</span> <span class="code-class">PhoneDecorator</span> <span class="code-keyword">implements</span> <span class="code-class">Phone</span> {
    <span class="code-keyword">protected</span> <span class="code-class">Phone</span> phone;

    <span class="code-keyword">public</span> <span class="code-function">PhoneDecorator</span>(<span class="code-class">Phone</span> phone) {
        <span class="code-keyword">this</span>.phone = phone;
    }
}

<span class="code-comment">// 摄像头装饰器</span>
<span class="code-keyword">class</span> <span class="code-class">CameraDecorator</span> <span class="code-keyword">extends</span> <span class="code-class">PhoneDecorator</span> {
    <span class="code-keyword">public</span> <span class="code-function">CameraDecorator</span>(<span class="code-class">Phone</span> phone) {
        <span class="code-keyword">super</span>(phone);
    }

    <span class="code-keyword">public</span> <span class="code-keyword">void</span> <span class="code-function">features</span>() {
        phone.<span class="code-function">features</span>();
        System.<span class="code-keyword">out</span>.println(<span class="code-string">"Added camera feature"</span>);
    }
}

<span class="code-comment">// 蓝牙装饰器</span>
<span class="code-keyword">class</span> <span class="code-class">BluetoothDecorator</span> <span class="code-keyword">extends</span> <span class="code-class">PhoneDecorator</span> {
    <span class="code-keyword">public</span> <span class="code-function">BluetoothDecorator</span>(<span class="code-class">Phone</span> phone) {
        <span class="code-keyword">super</span>(phone);
    }

    <span class="code-keyword">public</span> <span class="code-keyword">void</span> <span class="code-function">features</span>() {
        phone.<span class="code-function">features</span>();
        System.<span class="code-keyword">out</span>.println(<span class="code-string">"Added Bluetooth feature"</span>);
    }
}

<span class="code-keyword">public</span> <span class="code-keyword">class</span> <span class="code-class">DecoratorPatternDemo</span> {
    <span class="code-keyword">public</span> <span class="code-keyword">static</span> <span class="code-keyword">void</span> <span class="code-function">main</span>(String[] args) {
        <span class="code-class">Phone</span> basicPhone = <span class="code-keyword">new</span> <span class="code-class">BasicPhone</span>();
        <span class="code-class">Phone</span> phoneWithCamera = <span class="code-keyword">new</span> <span class="code-class">CameraDecorator</span>(basicPhone);
        <span class="code-class">Phone</span> phoneWithBluetooth = <span class="code-keyword">new</span> <span class="code-class">BluetoothDecorator</span>(basicPhone);
        <span class="code-class">Phone</span> phoneWithBoth = <span class="code-keyword">new</span> <span class="code-class">BluetoothDecorator</span>(<span class="code-keyword">new</span> <span class="code-class">CameraDecorator</span>(basicPhone));

        basicPhone.<span class="code-function">features</span>();
        System.<span class="code-keyword">out</span>.println(<span class="code-string">"----"</span>);
        phoneWithCamera.<span class="code-function">features</span>();
        System.<span class="code-keyword">out</span>.println(<span class="code-string">"----"</span>);
        phoneWithBluetooth.<span class="code-function">features</span>();
        System.<span class="code-keyword">out</span>.println(<span class="code-string">"----"</span>);
        phoneWithBoth.<span class="code-function">features</span>();
    }
}
                </code></pre>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="bg-white p-8 rounded-lg shadow-md">
            <div class="flex items-start">
                <div class="text-purple-600 text-3xl mr-4">
                    <i class="fas fa-lightbulb"></i>
                </div>
                <div>
                    <h2 class="text-2xl font-bold mb-4">关键总结</h2>
                    <p class="text-gray-600 leading-relaxed mb-4">
                        装饰器设计模式允许我们在不改变现有代码的基础上，动态地为对象添加功能。通过组合不同的装饰器，我们可以灵活地构建出不同组合的功能，满足不同的需求。
                    </p>
                    <p class="text-gray-600 leading-relaxed">
                        这种模式特别适用于需要动态、灵活地扩展对象功能的场景，同时遵循了开放封闭原则，使系统更易于维护和扩展。
                    </p>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-10">
        <div class="container mx-auto px-4">
            <div class="text-center">
                <h3 class="text-xl font-bold mb-2">技术小馆</h3>
                <p class="mb-4">探索设计模式的魅力世界</p>
                <a href="http://www.yuque.com/jtostring" class="text-purple-400 hover:text-purple-300 transition-colors duration-200">
                    <i class="fas fa-external-link-alt mr-1"></i> www.yuque.com/jtostring
                </a>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'dark',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true
            }
        });
    </script>
</body>
</html>
```